home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / games2 / rotise12.zip / AVL.H < prev    next >
C/C++ Source or Header  |  1992-04-03  |  2KB  |  87 lines

  1. /*    avl.h        Definitions for avl routines
  2.  
  3.     Copyright 1988,1989,1990 Zinn Computer Company
  4.             by Mark E. Mallett
  5.  
  6.     All Rights Reserved
  7.     All rights reserved;
  8.     This software may be used at will, provided that all credits
  9. and style be left in place, and that its distribution is not restricted.
  10. Bug fixes and improvements are welcomed, please send these back to
  11. me at mem@zinn.MV.COM
  12.  
  13.  
  14. */
  15.  
  16. #ifndef    H_AVL                /* Prevent multiple inclusions */
  17. #define    H_AVL
  18.  
  19. #ifndef    NULL
  20. #define    NULL    0
  21. #endif    /* NULL */
  22.  
  23.  
  24. #ifndef    AREG1
  25.     /* Prioritized register attributes -- adjust these to 
  26.        something close to what's supported by the particular
  27.        compiler being used. */
  28. #define    AREG1        register
  29. #define    AREG2        register
  30. #define    AREG3     register
  31. #define    AREG4
  32. #define    AREG5
  33. #define    AREG6
  34. #define    AREG7
  35. #define    AREG8
  36.  
  37. #define    DREG1        register
  38. #define    DREG2        register
  39. #define    DREG3        register
  40. #define    DREG4
  41. #define    DREG5
  42. #define    DREG6
  43. #define    DREG7
  44. #define    DREG8
  45.  
  46. #endif    /* AREG1 */
  47.  
  48.     /* Structures */
  49.  
  50. /* Structure of an avl tree node.  Note that this node is meant to
  51.    be used as a header or component of an application-specific structure,
  52.    since there is no key or data information present in the avlnode
  53.    structure.
  54. */
  55.  
  56. typedef                    /* A node in an AVL tree */
  57.   struct avlnode {
  58.     struct avlnode *n_leftP;        /* Ptr to left subtree */
  59.     struct avlnode *n_rightP;        /* Ptr to right subtree */
  60.     int        n_balance;        /* Balance count */
  61.   } AVLNODE;
  62.  
  63.  
  64. typedef                    /* The header for an AVL tree */
  65.   struct {
  66.     /* Tree parameters */
  67.     AVLNODE    *t_rootP;        /* Ptr to root node */
  68.     int        t_nodeC;        /* Number of nodes */
  69.  
  70.     /* Handler functions for the tree */
  71.     int        (*t_cmpkey)();        /* Compare two keys */
  72.     AVLNODE    *(*t_mknode)();        /* Node maker */
  73.     int        (*t_rmnode)();        /* Node destroyer */
  74.   } AVLTREE;
  75.  
  76.  
  77. /* Routine declarations: */
  78. #if    0                /* These are in proto.h for bb */
  79. /* extern    AVLTREE    *avlnew(); */
  80. extern    AVLNODE    *avlfind();
  81. extern    void    avlwalk();
  82. extern    int    avlinsert();
  83. extern    int    avldelete();
  84. #endif
  85.  
  86. #endif    /* H_AVL; */
  87.